#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //设置密码的显示模式
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::compare()
{
    if(ui->lineEdit->text().isEmpty()&&ui->lineEdit_2->text().isEmpty())
    {
        ui->label->setText("当前密码为空");
    }
    else if(ui->lineEdit->text()==ui->lineEdit_2->text())
    {
        ui->label->setText("密码相同");
    }
    else
    {
        ui->label->setText("密码不相同");
    }
}


//当文本发生改变时会触发信号，并调用这个槽函数
void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    //(void) arg1;
    compare();
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
    (void) arg1;
    compare();
}
